Skip to content

Mention extension in unused param warning #23132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

som-snytt
Copy link
Contributor

Fixes #23125

Make the message more verbose by stating the extension method name.

This could be improved by only adding words if the param pos is on a different line from the method pos.

@som-snytt som-snytt marked this pull request as ready for review May 9, 2025 22:34
@Gedochao Gedochao requested a review from tgodzik May 15, 2025 06:16
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with the minor nitpick

Comment on lines +503 to +504
//println(infos.defs.mkString("DEFS\n", "\n", "\n---"))
//println(infos.refs.mkString("REFS\n", "\n", "\n---"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//println(infos.defs.mkString("DEFS\n", "\n", "\n---"))
//println(infos.refs.mkString("REFS\n", "\n", "\n---"))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could use the local convention

// checkConsistent() // DEBUG

which appears to have a special code

// println(owner.info.decls.toList.map(_.debugString).mkString("\n  ")) // !!! DEBUG

or add config.Printers.lint but frankly I never edit that config to enable printing. If I want to enable some typr.println I just remove typr. The many layers of just getting debug output from a test means I don't get debug output.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that's on purpose then it's fine, thanks for explaning!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, normally I have been deleting it, but I've written it a few times now. Uncommented would definitely be accidental; I should add the DEBUG for easy grepping. Or maybe just add the debug printer for lint. I will try that when fully caffeinated.

def show(s: String) = s
extension (s: String)(using Show) // warn not used in repeat
def echo = println(summon[Show].show(s))
def repeat = s * 2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's OK if the warning is repeated for a second method. Alternatively, collect warnings by "site" and/or "origin" for helpful grouping. Maybe a future enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive unused given in extensions
2 participants